#include "widget.h"
#include "ui_widget.h"
#include <QGridLayout>
#include <QPushButton>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QGridLayout* layout = new QGridLayout();

    QPushButton* button1 = new QPushButton(this);
    button1->setText("按钮1");
    layout->addWidget(button1,0,1);
    //layout->setSpacing(2);
    //layout->setHorizontalSpacing(50);
    QPushButton* button2 = new QPushButton(this);
    button2->setText("按钮2");
    layout->addWidget(button2,0,2);
    QPushButton* button3 = new QPushButton(this);
        button3->setText("按钮3");
    layout->addWidget(button3,1,1);
    QPushButton* button4 = new QPushButton(this);
        button4->setText("按钮4");
    layout->addWidget(button4,1,2);
    //layout->setColumnStretch(1,2);
    layout->setColumnStretch(1,1);
    layout->setColumnStretch(2,2);
    this->setLayout(layout);

}

Widget::~Widget()
{
    delete ui;
}

